package edu.gdkm.demo3;

import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入要比较的整数的个数：");
        int n=sc.nextInt();
        int[]number=new int[n];
        System.out.println("请依次输入"+n+"个整数来找出最大值和最小值：");
        for (int i = 0; i < number.length; i++) {
            number[i]=sc.nextInt();
        }
        System.out.println("最大值为"+max(number));
        System.out.println("最小值为"+small(number));
    }
    public static int max(int[] number){
        int max=number[0];
        for (int i = 0; i < number.length; i++) {
            if(number[i]>max){
                max=number[i];
            }
        }
        return max;
    }
    public static int small(int[] number){
        int small=number[0];
        for (int i = 0; i < number.length; i++) {
            if(number[i]<small){
                small=number[i];
            }
        }
        return small;
    }

}

